import java.lang.Math;

public class Vector3 {
	public double x;
	public double y;
	public double z;
	
	public Vector3()
	{
		x = y = z = 0.0;
	}
	
	public Vector3(double x, double y, double z)
	{
		this.x = x;
		this.y = y;
		this.z = z;
	}
	
	public String toString()
	{
		return "(" + x + ", " + y + ", " + z + ")";
	}
	
	public final double length()
	{
		return Math.sqrt(x * x + y * y + z * z);
	}
	
	public final double sqrLength()
	{
		return x * x + y * y + z * z;
	}
	
	public Vector3 normalize()
	{
		double inv = 1 / length();
		return new Vector3(x * inv, y * inv, z * inv);
	}
	
	public Vector3 negate()
	{
		return new Vector3(-x, -y, -z);
	}
	
	public Vector3 add(final Vector3 v)
	{
		return new Vector3(x + v.x, y + v.y, z + v.z);
	}
	
	public Vector3 sub(final Vector3 v)
	{
		return new Vector3(x - v.x, y - v.y, z - v.z);
	}
	
	public Vector3 mul(final double f)
	{
		return new Vector3(x * f, y * f, z * f);
	}
	
	public Vector3 div(final double f)
	{
		double invF = 1 / f;
		return new Vector3(x * invF, y * invF, z * invF);
	}
	
	public double dot(final Vector3 v)
	{
		return (x * v.x + y * v.y + z * v.z);
	}
	
	public Vector3 cross(final Vector3 v)
	{
		return new Vector3(-z * v.y + y * v.z, z * v.x - x * v.z, -y * v.x + x * v.y); 
	}
}
